/*
 * @lc app=leetcode.cn id=2000 lang=typescript
 *
 * [2000] 反转单词前缀
 */

// @lc code=start
function reversePrefix(word: string, ch: string): string {
    const index = word.indexOf(ch);
    if (index === -1) {
        return word;
    }
    const prefix = word
        .slice(0, index + 1)
        .split("")
        .reverse()
        .join("");
    return prefix + word.slice(index + 1);
}
// @lc code=end
